package games.go.controllers
{
	import games.go.models.GoFactory;
	import games.go.models.vo.GUser;
	
	import models.ConfigModel;
	import models.StratusConnection;
	import models.vo.RoomVO;
	import models.vo.UserVO;
	
	import views.GameWindow;
	import views.WaitWindow;

	public class GoAppCtrller
	{
		[DexterBinding]
		public var stratus:StratusConnection;
		[DexterEvent]
		public function goAppStart():void{
			sendDexterEvent("setClassFactory",new GoFactory());
			stratus.Connect("go");
		}
		[DexterEvent]
		public function goAppShutdown():void{
			stratus.close();
		}
		[DexterEvent]
		public function goBegin():void{
			sendDexterEvent("sendToRoom","goBegin");
			sendDexterEvent("begin",opponent);
		}
		[DexterEvent]
		public function $goBegin():void{
			if(UserVO.self.room){
				sendDexterEvent("begin",opponent);
			}
		}
		private function get opponent():GUser{
			var roomVO:RoomVO = sendDexterEvent("getRoom",UserVO.self.room);
			return roomVO.getItemAt(1-UserVO.self.part) as GUser;
		}
	}
}